<?php slot('theme','now'); ?>
<style>
    .GrenCont IMG{max-width: 860px;};
</style>
<div class="W100p mainptn">
	<div class="Cw1280">
        <!--成长烦恼-->
        <div class="Czfn_div" style="padding-top:20px; width:860px;">
            <div class="DetitleCt"><?php echo $theme->getTitle(); ?></div>
            <div class="Delistd bgno">
            	<div class="Delistdc">
                    <div class="Depto"><img src="<?php echo $theme->getUser()->getCover(); ?>" width="38" height="38"></div>
                    <div class="DeBcont">
                        <div class="Deuntx" style="padding-top:0px;"><strong><?php echo $theme->getUser()->getNickname(); ?></strong> | <span style="font-size:14px; color:#808080;"><?php echo $theme->getUser()->getCity(); ?> <?php echo $theme->getChildrenInfo(); ?></span></div>
                        <div class="Deuntx"><span style="color:#808080;font-size:14px;"><?php echo $theme->getCreatedAt(); ?></span></div>
                    </div>
                </div>
                <div class="GrenCont" style="max-width: 860px;">
                    <?php if($theme->getHasCover()): ?>
                    <?php foreach($theme->getImg() as $img): ?>
                    <img src="<?php echo $img->getThumbImg('showthemeimg'); ?>" /><br/><br/>
                    <?php endforeach; ?>
                    <?php endif; ?>
                    <p>
                        <?php echo $theme->getRaw('content'); ?>
                    </p>
                    
                </div>
            </div>
            
            <div class="XzPl">
            	<div class="zxpltitle">小组评论</div>
                <form action="<?php echo url_for('theme/create_comment'); ?>" method="post" class="zxplForm" onSubmit="return CheckForm();">
                	<textarea name="content" id="plcontent"></textarea>
                        <input type="hidden" name="theme_id" value="<?php echo $theme->getId(); ?>" />
                    <input type="submit" name="" value="发表评论">
                </form>
            </div>
			
            <?php include_component('theme', 'comment_list',array('theme'=>$theme)); ?>
            
            
        </div>
        
        <!--右边-->
        <div class="DeRight" style="width:360px;">
        	<div class="Detitle2"><h1>小组信息</h1></div>
            <div class="xzxxti">
                <div class="xzxxpto"><a href="<?php echo url_for('theme/group?id='.$theme->getGroup()->getId()); ?>"><img src="<?php echo $theme->getGroup()->getThumbCover('groupcover'); ?>" height="60" width="60" /></a></div>
                <div class="xzxxc">
                    <div class="xzname"><a href="<?php echo url_for('theme/group?id='.$theme->getGroup()->getId()); ?>"><?php echo $theme->getGroup()->getName(); ?></a></div>
                        <div class="xzguanz"><span id="attention_people_num"><?php echo $theme->getGroup()->getStatistical()->getPeopleNum(); ?>个成员　</span>
                        <?php if($sf_user->isAuthenticated()): ?>
                            <a href="javascript:void(0);" id="attention" group_id="<?php echo $theme->getGroup()->getId(); ?>" attenthon="<?php echo $theme->getGroup()->hasUserById($sf_user->getAttribute('user_id')); ?>" >
                                <?php if($theme->getGroup()->hasUserById($sf_user->getAttribute('user_id')) == 0): ?>
                                +加入小组
                                <?php else: ?>
                                -退出小组
                                <?php endif; ?>
                            </a>
                        <?php else: ?>
                        <a href="javascript:void(0);"  onclick="alert('请先登入!');" >+加入小组</a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            
        	<div class="Detitle2"><h1>小组最新话题</h1><h3>话题数：<a href=""><?php echo $theme->getGroup()->getThemeNum(); ?></a></h3></div>
                <?php if($new_theme): ?>
            <div class="PicTitleS" style="padding-bottom:15px;">
            	<div class="PTimg" style="width:125px; height:70px;"><img src="<?php echo $new_theme['cover'].'!articlecover2'; ?>" width="125" height="70"></div>
                <div class="PTxt" style="width:225px;">
                	<div class="ti"><a href=""><?php echo $new_theme['title']; ?></a></div>
                    <div class="st" style="padding-top:10px;"><?php echo mb_strimwidth($new_theme['title'], 0, 23, '...', 'UTF8'); ?>&nbsp;&nbsp;<a href="<?php echo url_for('theme/show?id='.$new_theme['id']); ?>">详细</a></div>
                </div>
            </div>
                <?php endif; ?>
            <div class="Clist">
                <?php foreach($themes as $key=>$n_theme): ?>
            	<li><a href="<?php echo url_for('theme/show?id='.$n_theme->getId()); ?>">&middot;<?php echo $n_theme->getTitle(); ?></a></li>
                <?php endforeach; ?>
            </div>
            
        </div>
        
    </div>
</div>
<script type="text/javascript">
<?php if($sf_user->hasFlash('error') ): ?>
layer.msg('<?php echo $sf_user->getFlash('error'); ?>');
<?php endif; ?>
<?php if($sf_user->hasFlash('success')): ?>
layer.msg('<?php echo $sf_user->getFlash('success'); ?>');
<?php endif; ?>
    
$(document).ready(function(){
    
    $("#attention").on('click',function(){
        var att_button = $(this);
        var w_id = $(this).attr('group_id');
        var is_attenthion = $(this).attr('attenthon');
        var url = '';
        var text = '',attenthon = 0;
        console.log(is_attenthion);
        if(is_attenthion == 0){
            url = "<?php echo url_for('theme/attention'); ?>";
            text = '-退出小组';
            attenthon = 1;
        }else{
            url = "<?php echo url_for('theme/unattention'); ?>";
            text = '+加入小组';
            attenthon = 0;
        }
        
        $.post(url,{"group_id":w_id},function(data){
            var msg = eval("("+data+")");
            
            if(msg.error == 0){
                att_button.text(text).attr('attenthon',attenthon);
                var num = msg.data.people_num;
                var people = msg.data.people;
                $("#attention_people_num").text(num);
            }
            layer.msg(msg.msg);
        });
        
    });
    
});

function CheckForm(){
        var is_login = '<?php echo (int)$sf_user->isAuthenticated(); ?>';
        
        if(is_login == 0){
            alert('请先登入！');
            return false;
        }
        
	plcontent = $('#plcontent').val();
	if(plcontent.length<=0){
		layer.msg('评论还是要写点啥吧！');
		return false;
	}
	return true;
}
</script>